package com.aistar.service.job.impl;

import com.aistar.mapper.RecruitmentLabelMapper;
import com.aistar.mapper.TagMapper;
import com.aistar.model.entity.Tag;
import com.aistar.service.job.ITagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TagServiceImpl implements ITagService {
    @Autowired
    private TagMapper tagMapper;

    @Autowired
    private RecruitmentLabelMapper recruitmentLabelMapper;

    @Override
    public List<Tag> searchTag() {
        return tagMapper.findAll();
    }

    @Override
    public String searchDetails(Integer id) {
        return tagMapper.findById(id);
    }

    @Override
    public List<String> findTagByRecruitmentId(Integer recruitmentId) {
        // 根据职位id获取该职位的标签id
        List<Integer> tagId = recruitmentLabelMapper.findTagId(recruitmentId);
        // 根据职位id获取职位详情
        List<String> tagList = new ArrayList<>();
        for (Integer i : tagId) {
            String tag = tagMapper.findById(i);
            tagList.add(tag);
        }
        return tagList;
    }
}
